package com.example.iitematicviewer.api.machine;

import com.alibaba.fastjson.JSONObject;
import com.example.iitematicviewer.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 归档
 */
@RequestMapping("/machine")
@RestController
public class MachineController {

    @Autowired
    private MachineService service;

    @Autowired
    private MachineAsyncMsgService asyncMsgService;

    @RequestMapping("/selectOne")
    public ResultVO selectOne(@RequestBody JSONObject param){
        ResultVO resultVO = new ResultVO();
        //判空
        service.judgingEmptinessById(param);
        return asyncMsgService.selectOne(param,resultVO);
    }

    @RequestMapping("/selectAll")
    public ResultVO selectAll(){
        ResultVO resultVO = new ResultVO();
        return service.selectAll(resultVO);
    }

    @RequestMapping("/insert")
    public ResultVO insert(@RequestBody JSONObject param){
        ResultVO resultVO = new ResultVO();
        //判空
        service.judgingEmptiness(param);
        //新增
        return service.insert(param,resultVO);
    }

    @RequestMapping("/update")
    public ResultVO update(@RequestBody JSONObject param){
        ResultVO resultVO = new ResultVO();
        //判空
        service.judgingEmptinessById(param);
        service.judgingEmptiness(param);
        return service.update(param,resultVO);
    }

    @RequestMapping("/delete")
    public ResultVO delete(@RequestBody JSONObject param){
        ResultVO resultVO = new ResultVO();
        service.judgingEmptinessById(param);
        return service.delete(param,resultVO);
    }
}
